package claim.geoobj;

import java.util.HashMap;
import java.util.Map;

import claim.fuzzy.MembershipFunction;
import claim.fuzzy.SqrtMembershipFunction;

public class ClassConfiguration {

		private Map<String, Double> bufferSizes;
		private Map<String, MembershipFunction> membershipFunctions;

		public ClassConfiguration() {
			this.bufferSizes = new HashMap<String, Double>();
			this.membershipFunctions = new HashMap<String, MembershipFunction>();
		}

		public double getBufferSize(String classId0, String classId1) {
			if (bufferSizes.containsKey(getKey(classId0, classId1))) {
				return bufferSizes.get(getKey(classId0, classId1));
			} else {
				return Buffer.DEFAULT_BUFFER_SIZE;
			}
		}
		
		public void setBufferSize(String classId0, String classId1, double size) {
			this.bufferSizes.put(getKey(classId0, classId1), size);
			this.bufferSizes.put(getKey(classId1, classId0), size);
		}
		
		

		public MembershipFunction getMembershipFunction(String classId0, String classId1) {
			if (membershipFunctions.containsKey(getKey(classId0, classId1))) {
				return membershipFunctions.get(getKey(classId0, classId1));
			} else {
				return MembershipFunction.DEFAULT_MEMBERSHIP_FUNCTION;
			}
			
		}

		public void setMembershipFunction(String classId0, String classId1, MembershipFunction membershipFunction) {
			this.membershipFunctions.put(getKey(classId0, classId1), membershipFunction);
		}
		
		private String getKey(String objClass0, String objClass1) {
			return objClass0 + "<->" + objClass1;
		}
}
